package com.transaction.demo.base.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

import com.transaction.demo.base.biz.SysUserBiz;
import com.transaction.demo.base.config.BaseConfig;
import com.transaction.demo.base.service.SysMenuService;
import com.transaction.demo.base.service.SysRoleService;
import com.transaction.demo.base.service.SysUserRoleService;
import com.transaction.demo.base.vo.req.SaveUserRoleListReqVo;
import com.transaction.demo.base.vo.req.UserLoginReqVo;
import com.transaction.demo.base.vo.resp.UserLoginRespVo;
import com.transaction.demo.base.vo.resp.UserMenuResp;
import com.transaction.demo.base.vo.resp.UserRoleResp;
import com.transaction.demo.common.util.ResultPage;
import com.transaction.demo.base.vo.req.SysUserReqVo;
import com.transaction.demo.base.vo.req.SysUserListReqVo;
import com.transaction.demo.base.vo.req.SysUserAddReqVo;
import com.transaction.demo.base.vo.req.SysUserUpdateReqVo;
import com.transaction.demo.base.vo.resp.SysUserRespVo;
import com.transaction.demo.base.service.SysUserService;

/**
 * 描述：用户信息表
 * 作者：马庆智
 * 日期：2023/03/28 17:07:15
 */
@Slf4j
@Service
public class SysUserServiceImpl implements SysUserService {

	@Autowired
	private BaseConfig baseConfig;

	@Autowired
	private SysUserBiz sysUserBiz;

	@Autowired
	private SysUserRoleService userRoleService;

	@Autowired
	private SysMenuService menuService;

	@Autowired
	private SysRoleService roleService;

	/**
	 * 查询用户信息表
	 *
	 * @param sysUser 请求参数
	 * @return SysUserResp
	 * @author 马庆智
	 * @date: 2023/03/28 17:07:15
	 */
	@Override
	public SysUserRespVo querySysUser(SysUserReqVo sysUser) {

		return sysUserBiz.querySysUser(sysUser);
	}

	/**
	 * 查询用户信息表列表
	 *
	 * @param sysUser 请求参数
	 * @return SysUserResp
	 * @author 马庆智
	 * @date: 2023/03/28 17:07:15
	 */
	@Override
	public ResultPage<SysUserRespVo> querySysUserList(SysUserListReqVo sysUser) {

		return sysUserBiz.querySysUserList(sysUser);

	}

	/**
	 * 添加用户信息表
	 *
	 * @param addReq 请求参数
	 * @return int
	 * @author 马庆智
	 * @date: 2023/03/28 17:07:15
	 */
	@Override
	public int saveSysUser(SysUserAddReqVo addReq) {

		return sysUserBiz.saveSysUser(addReq);
	}

	/**
	 * 删除用户信息表
	 *
	 * @param ids 请求参数
	 * @return int
	 * @author 马庆智
	 * @date: 2023/03/28 17:07:15
	 */
	@Override
	public int deleteSysUser(String ids) {
		return sysUserBiz.deleteSysUser(ids);
	}

	/**
	 * 更新用户信息表
	 *
	 * @param updateReq 请求参数
	 * @return int
	 * @author 马庆智
	 * @date: 2023/03/28 17:07:15
	 */
	@Override
	public int updateSysUser(SysUserUpdateReqVo updateReq) {

		return sysUserBiz.updateSysUser(updateReq);
	}

	/**
	 * 用户登录
	 *
	 * @param record 登录参数
	 * @return UserLoginResp
	 * @author 马庆智
	 * @date: 2023/3/29 16:14
	 */
	@Override
	public UserLoginRespVo login(UserLoginReqVo record) {

		return sysUserBiz.login(record);
	}

	/**
	 * 查询用户菜单
	 *
	 * @param userId 用户id
	 * @return SysUserResp
	 * @author 马庆智
	 * @date: 2023/3/29 17:14
	 */
	@Override
	public UserMenuResp queryUserMenuList(Integer userId) {

		return sysUserBiz.queryUserMenuList(userId);

	}

	/**
	 * 用户角色
	 *
	 * @param userId 用户id
	 * @return List<UserRoleResp>
	 * @author 马庆智
	 * @date: 2023/3/30 9:21
	 */
	@Override
	public UserRoleResp queryUserRoleList(Integer userId) {

		return sysUserBiz.queryUserRoleList(userId);
	}

	/**
	 * 分配用户角色
	 *
	 * @param record 请求参数
	 * @return SysUserResp
	 * @author 马庆智
	 * @date: 2023/3/30 9:18
	 */
	@Override
	public Integer saveUserRoleList(SaveUserRoleListReqVo record) {

		return sysUserBiz.saveUserRoleList(record);
	}
}